package com.example.tyz1201.myaccount.Activity.Activity.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.tyz1201.myaccount.Activity.Activity.Model.ChooseStyleModel;
import com.example.tyz1201.myaccount.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by tyz1201 on 2016/4/10.
 */
public class ChoosedStyleAdapter extends BaseAdapter {

    List<ChooseStyleModel> styleMessages = new ArrayList<>();
    Context context;

    public ChoosedStyleAdapter(List<ChooseStyleModel> styleMessages, Context context) {
        this.styleMessages = styleMessages;
        this.context = context;
    }

    @Override
    public int getCount() {
        return styleMessages.size();
    }

    @Override
    public Object getItem(int position) {
        return styleMessages.get(position);
    }

    @Override
    public long getItemId(int position) {
        return styleMessages.get(position).getChooseStyleId();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.item_choose_style, parent, false);

        ImageView iv_choose = (ImageView) view.findViewById(R.id.iv_choose);
        iv_choose.setImageResource(styleMessages.get(position).getChooseStyleId());

        TextView tv_choose = (TextView) view.findViewById(R.id.tv_choose);
        tv_choose.setText(styleMessages.get(position).getChooseStyleName());

        return view;
    }
}
